<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="js/config.js"></script>
</head>
<body>
    <div class="login-container">
        <form id="loginForm">
            <input type="text" id="uid" placeholder="用户名" required>
            <input type="password" id="password" placeholder="密码" required>
            <button type="submit">登录</button>
        </form>
    </div>

    <script>
        document.getElementById('loginForm').addEventListener('submit', async (e) => {
            e.preventDefault();
            
            const data = {
                uid: document.getElementById('uid').value,
                password: document.getElementById('password').value
            };
            
            try {
                const response = await API.user.login(data);
                if (response.utype) {
                    // 登录成功，根据用户类型跳转
                    window.location.href = `/index.html?utype=${response.utype}`;
                }
            } catch (error) {
                alert('登录失败：' + error.message);
            }
        });
    </script>
</body>
</html> 